package com.zw.transition.services;

import com.zw.transition.common.JsonResult;
import com.zw.transition.entity.*;
import com.zw.transition.mapper.FlowMapper;
import com.zw.transition.mapper.UserMapper;
import com.zw.transition.util.BeanUtil;
import com.zw.transition.util.ServletUtils;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Author: China.sgl
 * @Date: 2019/9/16 09:11
 */
@Service
@SuppressWarnings("all")
public class IndexService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private LogService logService;
    @Autowired
    private FlowMapper flowMapper;
    @Autowired
    private AssemblyService assemblyService;

    /**
     * 修改密码
     */
    public int updatePwd(User user) {
        user.setPwd(new SimpleHash("MD5", user.getPwd(), ByteSource.Util.bytes(user.getAccount()), 8).toString());
        return userMapper.updatePwd(user);
    }

    /**
     * 申请质检列表
     */
    public List<FlowRoute> findApplyList(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) return null;
        List<FlowRoute> routes = flowMapper.findApplyList(parse);
        return routes;
    }

    /**
     * 完成的申请质检列表
     */
    public List<FlowRoute> findCompleteApplyList(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) {
            return null;
        }
        List<FlowRoute> routes = flowMapper.findCompleteApplyList(parse);
        return routes;
    }

    /**
     * 完成的质检列表
     */
    public List<FlowRoute> findCompleteApplyList1(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) {
            return null;
        }
        List<FlowRoute> routes = flowMapper.findCompleteApplyList1(parse);
        return routes;
    }

    /**
     * 完成的质检列表
     */
    public List<FlowRoute> findCompleteApplyList2(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) {
            return null;
        }
        List<FlowRoute> routes = flowMapper.findCompleteApplyList2(parse);
        return routes;
    }

    /**
     * 申请质检
     */
    @Transactional(rollbackFor = Exception.class)
    public JsonResult apply(FlowRoute route) {
        JsonResult jsonResult = new JsonResult();
        // 修改路线表数量 可申请数减少， 已申请数增加
        int num = flowMapper.updateRouteApply(route);
        if (num == 0) {
            FlowRoute flowRoute = flowMapper.getFlowRouteByPrimaryKey(route.getId());
            jsonResult.setType(JsonResult.ResultType.ERROR);
            jsonResult.setMsg("申请失败，因申请数量超过可申请数量,可申请数量为" + flowRoute.getMayApplyNum() + "个零件！");
        } else {
            // 生成转序单
            FlowTrans trans = new FlowTrans();
            trans.setRouteId(route.getId());
            trans.setNum(route.getApplyNum());
            User u = (User) ServletUtils.getSession().getAttribute("user");
            u = flowMapper.getUserById(u.getId());
            trans.setApplyCode(u.getAccount());
            trans.setApplyName(u.getName());
            trans.setApplyTime(new Date());
            if (u.getBranch() != null) {
                trans.setApplyDept(u.getBranch());
            }
            trans.setIsDel(0);
            trans.setStatus(1);
            flowMapper.addTrans(trans);
            jsonResult.setType(JsonResult.ResultType.SUCCESS);
            jsonResult.setMsg("申请成功！");
        }
        return jsonResult;
    }

    /**
     * 取消申请质检
     */
    @Transactional(rollbackFor = Exception.class)
    public int cancelApply(FlowTrans trans) {
        FlowTrans flowTrans = flowMapper.getTrans(trans.getId());
        FlowRoute flowRoute = flowMapper.findCurRoute(flowTrans);
        flowRoute.setApplyNum(flowTrans.getNum());
        int res = flowMapper.updateRouteApplyToCancelApply(flowRoute);
        //删除转序单
        res += flowMapper.deleteTrans(trans);
        //如果该序是首序则修改下料状态为未下料
//        if (flowRoute.getOrderNo() == 10 && !flowRoute.getRoute().equals("原料")){
//            FlowSheet flowSheet = flowMapper.getSheet(flowRoute);
//            flowSheet.setCutStatus(null);
//            flowMapper.updateFlowSheetCutStatusByPrimary(flowSheet);
//        }
        return res;
    }

    /**
     * 质检列表
     */
    public List<FlowModel> findCheckList(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) return null;
        return flowMapper.findCheckList(parse);
    }


    /**
     * 转序接收列表
     */
    public List<FlowModel> findRecList(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) return null;
        List<FlowModel> routes = flowMapper.findRecList(parse);
        return routes;
    }

    /**
     * 质检驳回
     */
    @Transactional(rollbackFor = Exception.class)
    public int reject(FlowTrans trans) {
        FlowTrans t = flowMapper.getTrans(trans.getId());
        if (t.getStatus() != 1) {
            return 0;
        }
        User u = (User) ServletUtils.getSession().getAttribute("user");
        t.setCheckCode(u.getAccount());
        t.setCheckName(u.getName());
        t.setCheckTime(new Date());
        if (u.getBranchName() != null) {
            t.setCheckDept(u.getBranchName());
        }
        t.setStatus(trans.getStatus() == null ? 4 : 5);
        t.setReason((trans.getReason() == null || trans.getReason().length() < 1) ? "质检不合格" : trans.getReason());
        // 如果作废， sheet表添加作废数量
        if (t.getStatus() == 5) {
            FlowRoute cur = flowMapper.findCurRoute(t);
            FlowSheet sheet = flowMapper.getSheet(cur);
            sheet.setInvalid(sheet.getInvalid() + t.getNum());
            flowMapper.updateSheetInvalid(sheet);
        }
        return flowMapper.updateRejectTrans(t);
    }

    /**
     * 质检合格
     */
    @Transactional(rollbackFor = Exception.class)
    public int success(FlowTrans trans) {

        Date currentDate = new Date();
        FlowTrans t = flowMapper.getTrans(trans.getId());
        if (t.getStatus() != 1) {
            return 0;
        }
        User u = (User) ServletUtils.getSession().getAttribute("user");
        u = flowMapper.getUserById(u.getId());
        t.setCheckCode(u.getAccount());
        t.setCheckName(u.getName());
        t.setCheckTime(currentDate);
        if (u.getBranch() != null) {
            t.setCheckDept(u.getBranch());
        }
        t.setYield(trans.getYield() == null ? 0 : 1);
        t.setResult(trans.getResult());
        t.setStatus(2);

        FlowRoute cur = flowMapper.findCurRoute(t);
        FlowRoute next = flowMapper.findNextRoute(cur);
        FlowSheet sheet = flowMapper.getSheet(cur);
        //获取零件总数
        int totalNum = sheet.getDrawNum() - sheet.getInvalid();
        cur.setCheckNum(cur.getCheckNum() + t.getNum());
        if (totalNum == cur.getCheckNum().intValue()) {
            cur.setStatus(4);
        } else {
            cur.setStatus(3);
        }
        cur.setRouteDate(currentDate);
        flowMapper.updateRouteCheck(cur);
        //获取最后一道序
        FlowRoute lastRoute = getLastRoute(cur);
        if (null != next && "转储".equals(next.getRoute())) {
            t.setStatus(3);
            next.setRecNum(next.getRecNum() + t.getNum());

            if (totalNum == next.getRecNum()) {
                next.setStatus(4);
            } else {
                next.setStatus(4);
                //检测改生产令全部最后一道序是否全部完成或未完成修改生产任务表的生产状态

            }
            flowMapper.updateRouteRecNum(next);
            next.setRouteDate(currentDate);
            flowMapper.updateRouteRouteDate(next);

//获取对应的库存信息如果没有则插入数据库，有则更新数量
            //执行入库
            HalfStore store = new HalfStore();
            store.setSheetId(sheet.getId());
            store.setNum(t.getNum());
            BeanUtil.copy(sheet, store);
            store.setStoreAddr(t.getApplyDept());
            //生成入库记录
            AsseHalfStoreRecord record = new AsseHalfStoreRecord();
            //根据 生产令编号 部分 专业 图号 获取对应的库存
            HalfStore existHalfStore = flowMapper.getExistHalfStore(store);
            if (existHalfStore != null) {
                existHalfStore.setNum(existHalfStore.getNum() + t.getNum());
                if (existHalfStore.getNum() <= existHalfStore.getDrawNum()) {
                    flowMapper.updateHalfStoreNumByPrimary(existHalfStore);
                    record.setStoreId(existHalfStore.getId());
                } else {
                    Exception exception = new Exception();
                    exception.printStackTrace();
                }
            } else {
                flowMapper.insertHalfStore(store);
                record.setStoreId(store.getId());
            }
            record.setProdNo(sheet.getProdNo());
            record.setSpecial(sheet.getSpecial());
            record.setPartId(sheet.getPartId());
            record.setDrawName(sheet.getDrawName());
            record.setDrawNo(sheet.getDrawNo());
            record.setDrawNum(t.getNum());
            record.setWeight(sheet.getWeight());
            record.setQuality(sheet.getQuality());
            record.setSpec(sheet.getSpec());
            record.setStoreType(1);
            record.setRecordType(1);
            record.setStoreAddr(t.getApplyDept());
            record.setStorageRegisterCode(t.getApplyCode());
            record.setStorageTime(currentDate);
            record.setCheckOpinion(t.getResult());
            flowMapper.insertAsseHalfStoreRecord(record);
            t.setRecordId(record.getId());

        }
        //如果最后道序是铆焊则根据接收数量判断把状态进行更改，部分接收是3，完全接收是4
        else if (next.getRoute().equals("参焊") && lastRoute.getRoute().equals("参焊") && lastRoute.getOrderNo() == next.getOrderNo()) {
            t.setStatus(3);
            //获取零件总数
            FlowRoute totalNumRoute = flowMapper.getFirstRoute(cur);
            next.setRecNum(next.getRecNum() + t.getNum());
            next.setMayApplyNum(0);
            if (totalNumRoute.getRecNum().intValue() > next.getRecNum().intValue()) {
                next.setStatus(3);
            } else {
                next.setStatus(4);

            }
            flowMapper.updateRouteRecNum(next);
        }

        //如果该序全部转序则修改对应任务的状态
        if (cur.getRoute().equals("铆焊") || cur.getRoute().equals("机加")) {
            int routeCount = flowMapper.getRoteCountBySheetId(cur.getRoute(),sheet.getProdNo());
            int routeCompleteCount = flowMapper.getRoteCompleteCountBySheetId(cur.getRoute(),sheet.getProdNo());
            Date start = currentDate;
            Date end = currentDate;
            if (routeCount == routeCompleteCount) {
                String tasCod = "";
                if (cur.getRoute().equals("铆焊")) {
                    tasCod = "t11";
                } else if (cur.getRoute().equals("机加")) {
                    tasCod = "t14";
                }
                flowMapper.updateTaskStatusAndEndDat(sheet.getProdNo(), tasCod, end, u.getDeptId(), u.getId());
            } else {
                String tasCod = "";
                if (cur.getRoute().equals("铆焊")) {
                    tasCod = "t11";
                } else if (cur.getRoute().equals("机加")) {
                    tasCod = "t14";
                }
                Date dataBaseStartDate = flowMapper.getDataBaseStartDate(sheet.getProdNo(), tasCod);
                if (dataBaseStartDate == null) {
                    flowMapper.updateTaskStatusAndStartDat(sheet.getProdNo(), tasCod, start, u.getDeptId(), u.getId());
                }
            }

        }
         flowMapper.updateCheckTrans(t);
        //检测改生产令全部最后一道序是否全部完成或未完成修改生产任务表的生产状态
        checkLastRouteIsFinished(sheet);
        return 1;
    }

    /**
     * 检测最后一道序是否转序完毕如果转序完毕则生产任务完成，如果未完成则是执行中
     */
    @Transactional(rollbackFor = Exception.class)
    void checkLastRouteIsFinished(FlowSheet sheet) {
        User u = (User) ServletUtils.getSession().getAttribute("user");
        //获取总数量
        int totalCount = flowMapper.getLastRouteTotalCount(sheet);
        //获取完成总数量
        int totalFinishedCount = flowMapper.getLastRouteTotalFinishedCount(sheet);
        if (totalCount == totalFinishedCount) {
            flowMapper.updateTaskStatusAndEndDat(sheet.getProdNo(), "t27", new Date(), u.getDeptId(), u.getId());
            flowMapper.updateReturnEndDate(sheet.getProdNo(), "r11", new Date(), u.getDeptId(), u.getId());
            assemblyService.udpCodStaAndDate(sheet.getProdNo(),1);
        } else {
            flowMapper.updateTaskStatusAndStartDat(sheet.getProdNo(), "t27", new Date(), u.getDeptId(), u.getId());
        }
    }


    /**
     * 接收
     */
    @Transactional(rollbackFor = Exception.class)
    public int rec(FlowTrans trans) {
        trans = flowMapper.getTrans(trans.getId());
        if (trans.getStatus() != 2) {
            return 0;
        }
        User u = (User) ServletUtils.getSession().getAttribute("user");
        u = flowMapper.getUserById(u.getId());
        trans.setRecCode(u.getAccount());
        trans.setRecName(u.getName());
        trans.setRecTime(new Date());
        trans.setRecDept(u.getBranch());
        trans.setStatus(3);
        flowMapper.updateRecTrans(trans);
        FlowRoute cur = flowMapper.findCurRoute(trans);
        //获取下一道序
        FlowRoute nextRoute = flowMapper.getNextRoute(cur);
        //获取零件总数
        FlowRoute totalNum = flowMapper.getFirstRoute(cur);
        //获取最后一道序
        FlowRoute lastRoute = getLastRoute(cur);
        //如果最后道序是参焊则根据接收数量判断把状态进行更改，部分接收是3，完全接收是4
        if (nextRoute.getRoute().equals("参焊") && lastRoute.getRoute().equals("参焊") && lastRoute.getOrderNo() == nextRoute.getOrderNo()) {
            nextRoute.setRecNum(nextRoute.getRecNum() + trans.getNum());
            nextRoute.setMayApplyNum(0);
            if (totalNum.getRecNum().intValue() > nextRoute.getRecNum().intValue()) {
                nextRoute.setStatus(3);
            } else {
                nextRoute.setStatus(4);
            }
            return flowMapper.updateRouteRecNum(nextRoute);
        }
        //非最后一道序则正常进行下下一道序修改成执行中
        else {
            FlowRoute route = flowMapper.findNextRoute(cur);
            route.setRecNum(route.getRecNum() + trans.getNum());
            route.setMayApplyNum(route.getMayApplyNum() + trans.getNum());
            route.setStatus(2);
            return flowMapper.updateRouteRecNum(route);
        }
    }

    /**
     * @methodName: getLastRoute
     * @description: 获取最后一道序
     * @param: cur
     * @return： com.zw.transition.entity.FlowRoute
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/4/16 13:56
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    private FlowRoute getLastRoute(FlowRoute cur) {
        return flowMapper.getLastRoute(cur);
    }

    /**
     * 查询 清单
     */
    public FlowSheet findSheet(String code) {
        QrParse parse = getQrParse(code);
        if (parse == null) return null;
        FlowSheet sheet = flowMapper.findSheet(parse);
        return sheet;
    }

    /**
     * 历史申请
     */
    public List<FlowModel> findHisApplyList() {
        User u = (User) ServletUtils.getSession().getAttribute("user");
        return flowMapper.findHisApplyList(u.getAccount());
    }

    /**
     * 历史接收
     */
    public List<FlowModel> findHisRecList() {
        User u = (User) ServletUtils.getSession().getAttribute("user");
        return flowMapper.findHisRecList(u.getAccount());
    }

    /**
     * 历史质检
     */
    public List<FlowModel> findHisCheckList() {
        User u = (User) ServletUtils.getSession().getAttribute("user");
        return flowMapper.findHisCheckList(u.getAccount());
    }

    /**
     * 二维码解析
     */
    private QrParse getQrParse(String code) {
        String[] arr = code.split("\\|");
        if (arr == null || arr.length < 4) {
            return null;
        }
        QrParse parse = new QrParse();
        parse.setProNo(arr[0]);
        parse.setDrawNo(arr[1]);
        parse.setPartId(arr[2]);
        parse.setCategory(arr[3]);
        return parse;
    }

    /**
     * 重新申请质检
     */
    public int repeatApply(Integer id) {
        return flowMapper.updateTransStatus(id, 1);
    }

    /**
     * 删除质检申请
     */
    @Transactional(rollbackFor = Exception.class)
    public int delApply(Integer id) {
        FlowTrans trans = flowMapper.getTrans(id);
        if (trans.getIsDel() == 1) {
            return 0;
        }
        flowMapper.updateTransIsdel(id, 1);
        FlowRoute route = flowMapper.findCurRoute(trans);
        route.setApplyNum(trans.getNum());
        return flowMapper.updateRouteDel(route);
    }

    /**
     * 取消接收
     */
    @Transactional(rollbackFor = Exception.class)
    public int cancelRec(FlowTrans trans) {
        trans = flowMapper.getTrans(trans.getId());
        if (trans.getStatus() != 3) {
            return 0;
        }
        User u = (User) ServletUtils.getSession().getAttribute("user");
        trans.setRecCode(null);
        trans.setRecName(null);
        trans.setRecTime(null);
        trans.setStatus(2);
        flowMapper.updateRecTrans(trans);
        FlowRoute cur = flowMapper.findCurRoute(trans);
        FlowRoute route = flowMapper.findNextRoute(cur);
        route.setRecNum(route.getRecNum() - trans.getNum());
        route.setMayApplyNum(route.getMayApplyNum() - trans.getNum());
        if (route.getRecNum().intValue() == 0) {
            route.setStatus(1);
        }
        return flowMapper.updateRouteRecNum(route);
    }


    /**
     * 取消质检
     */
    public int cancelCheck(FlowTrans trans) {
        FlowTrans t = flowMapper.getTrans(trans.getId());
        if (t.getStatus() == 1) {
            return 0;
        }
        FlowRoute cur = flowMapper.findCurRoute(t);
        FlowSheet sheet = flowMapper.getSheet(cur);
        boolean isPass = true;
        switch (t.getStatus()) {
            case 5: // 作废
                sheet.setInvalid(sheet.getInvalid() - t.getNum());
                flowMapper.updateSheetInvalid(sheet);
                break;
            case 4: // 正常驳回
                break;
            case 3: // 倒数第二序
                FlowRoute next = flowMapper.findNextRoute(cur);
                if ("转储".equals(next.getRoute())) {
                    //获取对应的入库记录
                    AsseHalfStoreRecord record = flowMapper.getAsseHalfStoreRecordByPrimaryKey(t.getRecordId());
                    //获取对应的库存
                    HalfStore halfStore = flowMapper.getHalfStore(record);
                    //如果
                    if (halfStore.getNum() < record.getDrawNum()) {
                        isPass = false;
                        break;
                    } else {
                        next.setRecNum(0);
                        next.setMayApplyNum(0);
                        next.setStatus(1);
                        flowMapper.updateRouteRecNum(next);
                        //生成对应的退库记录
                        AsseHalfStoreRecord returnStoreRecord = record;
                        returnStoreRecord.setRecordType(2);
                        returnStoreRecord.setReplaceId(record.getId());
                        returnStoreRecord.setStorageTime(new Date());
                        flowMapper.insertAsseHalfStoreRecord(returnStoreRecord);
                        halfStore.setNum(halfStore.getNum() - returnStoreRecord.getDrawNum());
                        flowMapper.updateHalfStoreNumByPrimary(halfStore);
                        t.setRecordId(null);
                    }
                } else if ("参焊".equals(next.getRoute())) {
                    next.setRecNum(0);
                    next.setMayApplyNum(0);
                    next.setStatus(1);
                    next.setRouteDate(null);
                    flowMapper.updateRoute(next);
                }
                break;
            case 2: // 正常质检
                break;
        }

        t.setCheckCode(null);
        t.setCheckName(null);
        t.setCheckTime(null);
        t.setReason(null);
        t.setResult(null);
        t.setYield(0);
        t.setStatus(1);
        t.setRecordId(null);

        cur.setCheckNum(cur.getCheckNum() - t.getNum());
//        if (cur.getCheckNum() == 9) {
//            cur.setStatus(2);
//        } else {
//            cur.setStatus(3);
//        }
        cur.setStatus(2);
        cur.setRouteDate(null);
        flowMapper.updateRouteCheck(cur);
        return flowMapper.updateCheckTrans(t);
    }

    /**
     * @methodName: getTrans
     * @description: 根据主键获取转序单
     * @param: id
     * @return： com.zw.transition.entity.FlowTrans
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/4/24 13:30
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    public FlowTrans getTrans(Integer id) {
        return flowMapper.getTrans(id);
    }

    /**
     * @methodName: getFlowRouteByPrimaryKey
     * @description: 根据主键获取对应的路线
     * @param: routeId
     * @return： com.zw.transition.entity.FlowRoute
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/4/24 13:35
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    public FlowRoute getFlowRouteByPrimaryKey(Integer routeId) {
        return flowMapper.getFlowRouteByPrimaryKey(routeId);
    }

    /**
     * @methodName: getNextFlowRouteByBefore
     * @description: 根据上序获取下序
     * @param: currentFlowRoute
     * @return： com.zw.transition.entity.FlowRoute
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/4/24 13:38
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    public FlowRoute getNextFlowRouteByBefore(FlowRoute currentFlowRoute) {
        return flowMapper.getNextFlowRouteByBefore(currentFlowRoute);
    }

    /**
     * @methodName: getFirstFlowTransBySheetId
     * @description: 获取首道序的转序单
     * @param: id
     * @return： com.zw.transition.entity.FlowTrans
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/5/21 13:01
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    public FlowTrans getFirstFlowTransBySheetId(Integer sheetId) {
        return flowMapper.getFirstFlowTransBySheetId(sheetId);
    }

    /**
     * @methodName: getFirstFlowRouteBySheetId
     * @description: 获取第一道序
     * @param: id
     * @return： com.zw.transition.entity.FlowRoute
     * @exception：
     * @author： 徐一贺 tel:18341916590
     * @designer： 陈欣
     * @leader： 陈欣 tel:18104194240
     * @date： 2021/5/21 13:10
     * @office: 智能控制设计科
     * @research institute： 智能控制设计所
     * @department： 机械设计院
     * @company: 辽宁忠旺机械设备制造有限公司
     * @group： 忠旺集团
     * @version: 1.0
     */
    public FlowRoute getFirstFlowRouteBySheetId(Integer sheetId) {
        return flowMapper.getFirstFlowRouteBySheetId(sheetId);
    }
}
